package com.wondersgroup.framework.widget.library.extjs.form;

import com.wondersgroup.framework.widget.codegen.CodeGenerator;
import com.wondersgroup.framework.widget.codegen.annotation.ObjectField;
import com.wondersgroup.framework.widget.codegen.expression.Expression;
import com.wondersgroup.framework.widget.codegen.expression.JSFactory;
import com.wondersgroup.framework.widget.codegen.expression.js.JSMethod;
import com.wondersgroup.framework.widget.library.extjs.ExtComponent;
import org.springframework.util.StringUtils;

public abstract class ExtField extends ExtComponent {

	@ObjectField(index = 4, mapping = "name")
	private String property;

	@ObjectField(index = 6, defaultValue = "false")
	private boolean disabled;

	@ObjectField(index = 2, defaultValue = "false")
	private boolean readOnly;

	@ObjectField(index = 5)
	private String value;

	@ObjectField(index = 3)
	private String renderTo;

	@ObjectField(index = 1)
	private String applyTo;
	private String formItems;

	@ObjectField(index = 7, defaultValue = "0")
	private String width;

	@ObjectField(index = 8, defaultValue = "false")
	private boolean autoWidth;

	@ObjectField(index = 9, mapping = "fieldLabel")
	private String label;

	@ObjectField(index = 11)
	private String cls;
	private String dataType = "string";

	@ObjectField(index = 20)
	private int tabIndex;
	private String extAttribute;

	@ObjectField(index = 10, token = true)
	private String validator;
	private String toolBarArray;
	private String statusBarArray;

	public String getValidator() {
		return this.validator;
	}

	public void setValidator(String paramString) {
		this.validator = paramString;
	}

	protected String getPushScript() {
		JSMethod localJSMethod;
		if (StringUtils.hasText(getFormItems())) {
			localJSMethod = JSFactory.DEFAULT.method(getFormItems() + ".push", new String[] { getId() });
			return CodeGenerator.generate(localJSMethod, new Expression[0]);
		}
		if (StringUtils.hasText(getToolBarArray())) {
			localJSMethod = JSFactory.DEFAULT.method(getToolBarArray() + ".push", new String[] { getId() });
			return CodeGenerator.generate(localJSMethod, new Expression[0]);
		}
		if (StringUtils.hasText(getStatusBarArray())) {
			localJSMethod = JSFactory.DEFAULT.method(getStatusBarArray() + ".push", new String[] { getId() });
			return CodeGenerator.generate(localJSMethod, new Expression[0]);
		}
		return "";
	}

	public ExtField(String paramString) {
		super(paramString);
	}

	public String getProperty() {
		return this.property;
	}

	public boolean isDisabled() {
		return this.disabled;
	}

	public boolean isReadOnly() {
		return this.readOnly;
	}

	public String getValue() {
		return this.value;
	}

	public String getRenderTo() {
		return this.renderTo;
	}

	public String getFormItems() {
		return this.formItems;
	}

	public void setProperty(String paramString) {
		this.property = paramString;
	}

	public void setDisabled(boolean paramBoolean) {
		this.disabled = paramBoolean;
	}

	public void setReadOnly(boolean paramBoolean) {
		this.readOnly = paramBoolean;
	}

	public void setValue(String paramString) {
		this.value = paramString;
	}

	public void setRenderTo(String paramString) {
		this.renderTo = paramString;
	}

	public void setFormItems(String paramString) {
		this.formItems = paramString;
	}

	public String getApplyTo() {
		return this.applyTo;
	}

	public void setApplyTo(String paramString) {
		this.applyTo = paramString;
	}

	public String getWidth() {
		return this.width;
	}

	public void setWidth(String paramInt) {
		this.width = paramInt;
	}

	public boolean isAutoWidth() {
		return this.autoWidth;
	}

	public void setAutoWidth(boolean paramBoolean) {
		this.autoWidth = paramBoolean;
	}

	public String getLabel() {
		return this.label;
	}

	public void setLabel(String paramString) {
		this.label = paramString;
	}

	public String getDataType() {
		return this.dataType;
	}

	public void setDataType(String paramString) {
		this.dataType = paramString;
	}

	public String getExtAttribute() {
		return this.extAttribute;
	}

	public void setExtAttribute(String paramString) {
		this.extAttribute = paramString;
	}

	public String getCls() {
		return this.cls;
	}

	public void setCls(String paramString) {
		this.cls = paramString;
	}

	public String getToolBarArray() {
		return this.toolBarArray;
	}

	public void setToolBarArray(String paramString) {
		this.toolBarArray = paramString;
	}

	public String getStatusBarArray() {
		return this.statusBarArray;
	}

	public void setStatusBarArray(String paramString) {
		this.statusBarArray = paramString;
	}

	public int getTabIndex() {
		return this.tabIndex;
	}

	public void setTabIndex(int paramInt) {
		this.tabIndex = paramInt;
	}
}